home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / gle-3.000 / gle-3 / gle / gprint.c < prev    next >
C/C++ Source or Header  |  1995-02-07  |  2KB  |  104 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <assert.h>
  6.  
  7. #ifndef unix
  8. #include <stdarg.h>
  9. #endif
  10. #include "glepro.h"
  11. int gprint_send(char *s);
  12. int g_message(char *s);
  13. char *line(int i);
  14. #define false 0
  15. #define true (!false)
  16. int this_line;
  17. int last_line;
  18. extern int trace_on;
  19. int gprint_cr;
  20. extern int ngerror;
  21. #ifdef unix
  22. void gprint_do(char *output)
  23. {
  24.     char output2[199];
  25.     char output3[99];
  26.     int len;
  27.  
  28.     output[80]=0;
  29.     output2[0] = 0;
  30.     if (!gprint_cr) {
  31.         ngerror++;
  32.         if (last_line != this_line  && !trace_on) {
  33.             sprintf(output2,"=== %s\n",line(this_line));
  34.             gprint_send(output2);
  35.         }
  36.         last_line = this_line;
  37.         sprintf(output2,"%d: ",this_line);
  38.         gprint_cr = true;
  39.     }
  40.     output[80] = 0;
  41.     strcat(output2,output);
  42.     gprint_send(output2);
  43.     scr_refresh();
  44. }
  45. #else
  46. void gprint(va_list arg_list, ...)
  47. /* Prints an error message */
  48. {
  49.      va_list arg_ptr;
  50.      char *format;
  51.     char output[281];
  52.     char output2[199];
  53.     char output3[99];
  54.     int len;
  55.  
  56.      va_start(arg_ptr, arg_list);
  57.      format = arg_list;
  58.     vsprintf(output, format, arg_ptr);
  59.     output[80]=0;
  60.     output2[0] = 0;
  61.     if (!gprint_cr) {
  62.         ngerror++;
  63.         if (last_line != this_line  && !trace_on) {
  64.             sprintf(output2,"=== %s\n",line(this_line));
  65.             gprint_send(output2);
  66.         }
  67.         last_line = this_line;
  68.         sprintf(output2,"%d: ",this_line);
  69.         gprint_cr = true;
  70.     }
  71.     output[80] = 0;
  72.     strcat(output2,output);
  73.     gprint_send(output2);
  74. }
  75. #endif
  76. char *(*etxt)[];
  77. int netxt;
  78. gprint_send(char *ss)
  79. {
  80.     int i;
  81.     static char buff[180];
  82.     char *s,*t;
  83.     if (strlen(ss) + strlen(buff) > 170) buff[0] = 0;
  84.     strcat(buff,ss);
  85.     if (etxt==0) etxt = myallocz(70*sizeof(char *));
  86. loop:    s = &buff[0];
  87.     while (*s != 0) {
  88.         if (*s == '\n') {
  89.             gprint_cr = false;
  90.             *s = 0;
  91.             g_message(buff);
  92.             if (netxt<50) {
  93.                 netxt++;
  94.                 if ((*etxt)[netxt]!=NULL) myfree((*etxt)[netxt]);
  95.                 (*etxt)[netxt] = sdup(buff);
  96.             }
  97.             memmove(buff,s+1,strlen(s+1)+1);
  98.             goto loop;
  99.         }
  100.         s++;
  101.     }
  102. }
  103.  
  104.